package mobile.game.core.support;

import com.google.protobuf.Message;
import com.google.protobuf.Message.Builder;

/**
 * @author gzoro
 *
 * 当输入流与输出流转换时， 可以用本队象作为中间类型
 */
public class Chunk {
	public byte[] buffer;
	public int offset;
	public int length;
	
	public Chunk() {
		
	}
	
	public Chunk(Builder msg) {
		this(msg.build());
	}
	
	public Chunk(Message msg) {
		this(msg.toByteArray());
	}
	
	public Chunk(byte[] buf) {
		buffer = buf;
		offset = 0;
		length = buf.length;
	}
	
	public Chunk(byte[] buf, int off, int len) {
		buffer = buf;
		offset = off;
		length = len;
	}

}
